package com.kk.permission.huawei.al00;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;

import com.kk.permission.GuideConst;
import com.kk.permission.IPermissionGuideStrategy;
import com.kk.permission.handler.ConfigHandler;
import com.kk.permission.huawei.HuaweiPermissionAccessbilityHandlerBase;
import com.kk.permission.huawei.HuaweiPermissionStrategyBase;
import com.kk.permission.utils.Permission;

import java.util.ArrayList;

public class HuaweiAL00PermissionStrategy extends HuaweiPermissionStrategyBase {
    public HuaweiPermissionAccessbilityHandlerBase getHandlerBase() {
        return null;
    }

    public HuaweiAL00PermissionStrategy(Context context) {
        super(context);
    }

    protected void actionReadCalllog() {
        super.actionReadCalllog();
        actionTrustApplicationPermission(true);
    }

    protected void actionReadContact() {
        super.actionReadContact();
        actionTrustApplicationPermission(true);
    }

    protected void actionTrustApplicationPermission(boolean z) {
        super.actionTrustApplicationPermission(z);
        try {
            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", GuideConst.HUAWEI_APP_PERMISSION_ACTIVITY_NAME);
            z = startIntentActivities(intent, GuideConst.TRUST_APPLICATION_PERMISSION, this.mAutoGuide);
//            final Intent intent2 = new Intent(this.mContext, OuterPermissionActivity.class);
//            intent2.putExtra(OuterPermissionActivity.VIEWSTUB_ID, R.layout.huawei_app_permission_guide_v2);
//            final boolean finalZ = z;
//            UiThreadExecutor.execute(new Runnable() {
//                public void run() {
//                    if (finalZ) {
//                        HuaweiAL00PermissionStrategy.this.mContext.startActivity(intent2);
//                    }
//                }
//            }, 100);
        } catch (Throwable e) {
        }
    }

    protected void actionAutoBootPermission() {
        super.actionAutoBootPermission();
        Intent intent = new Intent();
        intent.setClassName("com.huawei.systemmanager", GuideConst.HUAWEI_AUTO_START_PERMISSION_ACTIVITY_NAME);
        if (startIntentActivities(intent, GuideConst.AUTOBOOT_PERMISSION, this.mAutoGuide)) {
//            intent = new Intent(this.mContext, OuterPermissionActivity.class);
//            intent.putExtra(OuterPermissionActivity.VIEWSTUB_ID, R.layout.huawei_permission_general_guide);
//            intent.putExtra(OuterPermissionActivity.HUAWEI_GENERAL_GUIDE_HINTONE, StringUtils.getFullStringWithAppName(R.string.miui_permission_guide_template_one));
//            intent.putExtra(OuterPermissionActivity.HUAWEI_GENERAL_GUIDE_HINTTWO, this.mContext.getString(R.string.huawei_autoboot_protected_hinttwo_v2));
//            intent.putExtra(OuterPermissionActivity.HUAWEI_GENERAL_GUIDE_HINTTWO, this.mContext.getString(R.string.huawei_autoboot_protected_hinttwo_v1));
//            intent.putExtra(OuterPermissionActivity.HUAWEI_GENERAL_GUIDE_ALT, this.mContext.getString(R.string.huawei_permission_allowed));
//            intent.putExtra(OuterPermissionActivity.HUAWEI_GENERAL_GUIDE_VERSION, this.mVersion);
//            this.mContext.startActivity(intent);
//            PrefUtil.setKey("setted_autoboot_permission", true);
        }
    }

    /* JADX WARNING: Missing block: B:9:0x0074, code:
            r0 = move-exception;
     */
    /* JADX WARNING: Missing block: B:10:0x0075, code:
            com.cootek.base.tplog.TLog.printStackTrace(r0);
     */
    /* JADX WARNING: Missing block: B:11:0x0079, code:
            r0 = move-exception;
     */
    /* JADX WARNING: Missing block: B:12:0x007a, code:
            com.cootek.base.tplog.TLog.printStackTrace(r0);
     */
    /* JADX WARNING: Missing block: B:13:?, code:
            return;
     */
    /* JADX WARNING: Missing block: B:16:?, code:
            return;
     */
    protected void actionToastPermission() {
        /*
        r5 = this;
        super.actionToastPermission();
        r0 = r5.mVersion;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1 = new android.content.Intent;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1.<init>();	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "com.huawei.systemmanager";
        r3 = "com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity";
        r1.setClassName(r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "toast_permission";
        r3 = r5.mAutoGuide;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1 = r5.startIntentActivities(r1, r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        if (r1 == 0) goto L_0x007d;
    L_0x001b:
        r1 = new android.content.Intent;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = r5.mContext;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r3 = com.cootek.permission.OuterPermissionActivity.class;
        r1.<init>(r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "viewstub_id";
        r3 = com.cootek.permission.R.layout.huawei_permission_general_guide;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1.putExtra(r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "huawei_general_guide_hintone";
        r3 = com.cootek.permission.R.string.miui_permission_guide_template_one;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r3 = com.cootek.permission.utils.StringUtils.getFullStringWithAppName(r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1.putExtra(r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "huawei_general_guide_hinttwo";
        r3 = r5.mContext;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r4 = com.cootek.permission.R.string.huawei_permission_action_switch_on_v2;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r3 = r3.getString(r4);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1.putExtra(r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "huawei_general_guide_alt";
        r3 = r5.mContext;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r4 = com.cootek.permission.R.string.huawei_permission_allowed;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r3 = r3.getString(r4);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r1.putExtra(r2, r3);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r2 = "huawei_general_guide_version";
        r1.putExtra(r2, r0);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r0 = r5.mContext;	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        r0.startActivity(r1);	 Catch:{ ActivityNotFoundException -> 0x0060, SecurityException -> 0x005b }
        goto L_0x007d;
    L_0x005b:
        r0 = move-exception;
        com.cootek.base.tplog.TLog.printStackTrace(r0);
        goto L_0x007d;
    L_0x0060:
        r0 = new android.content.Intent;	 Catch:{ ActivityNotFoundException -> 0x0079, SecurityException -> 0x0074 }
        r0.<init>();	 Catch:{ ActivityNotFoundException -> 0x0079, SecurityException -> 0x0074 }
        r1 = "com.huawei.systemmanager";
        r2 = "com.huawei.systemmanager.mainscreen.MainScreenActivity";
        r0.setClassName(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0079, SecurityException -> 0x0074 }
        r1 = "toast_permission";
        r2 = r5.mAutoGuide;	 Catch:{ ActivityNotFoundException -> 0x0079, SecurityException -> 0x0074 }
        r5.startIntentActivities(r0, r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0079, SecurityException -> 0x0074 }
        goto L_0x007d;
    L_0x0074:
        r0 = move-exception;
        com.cootek.base.tplog.TLog.printStackTrace(r0);
        goto L_0x007d;
    L_0x0079:
        r0 = move-exception;
        com.cootek.base.tplog.TLog.printStackTrace(r0);
    L_0x007d:
        return;
        */
        //throw new UnsupportedOperationException("Method not decompiled: com.cootek.permission.huawei.al00.HuaweiAL00PermissionStrategy.actionToastPermission():void");
    }

    protected void actionBackgroundPermisssion() {
        super.actionBackgroundPermisssion();
        try {
            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", GuideConst.HUAWEI_BACKGROUND_PROTECT_PERMISSION_ACTIVITY_NAME);
            if (startIntentActivities(intent, GuideConst.BACKGROUND_PROTECT_PERMISSION, this.mAutoGuide)) {
//                intent = new Intent(this.mContext, OuterPermissionActivity.class);
//                intent.putExtra(OuterPermissionActivity.VIEWSTUB_ID, R.layout.general_permission_guide_mask);
//                intent.putExtra(OuterPermissionActivity.GUIDEPIC_ID, WrapViewGenerator.getInstance().getViewByResId(R.drawable.huawei_background_permission_item_v7));
//                intent.putExtra(OuterPermissionActivity.GUIDE_HINTONE, StringUtils.getFullStringWithAppName(R.string.miui_permission_guide_template_one));
//                intent.putExtra(OuterPermissionActivity.GUIDE_HINTTWO, StringUtils.getFullStringWithAppName(R.string.huawei_background_protected_hinttwo_v2));
//                this.mContext.startActivity(intent);
            }
        } catch (Throwable e) {
        }
    }

    protected void actionWhiteListPermisssion() {
        super.actionWhiteListPermisssion();
        try {
            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.mainscreen.MainScreenActivity");
            startIntentActivities(intent, "white_list", this.mAutoGuide);
        } catch (Throwable e) {
        }
    }

    protected void actionPermissionDeny(int i) {
        if (3 == i || 1 == i || 2 == i) {
            actionTrustApplicationPermission(true);
            return;
        }
        throw new IllegalArgumentException();
    }

    protected void actionCallogOrContactPermission() {
        super.actionCallogOrContactPermission();
        actionTrustApplicationPermission(true);
    }

    protected void actionDozePermission() {
        super.actionDozePermission();
        try {
            final boolean startIntentActivities = startIntentActivities(new Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"), GuideConst.DOZE_PERMISSION, this.mAutoGuide);
//            final Intent intent = new Intent(this.mContext, OuterTwoStepPermissionActivity.class);
//            intent.putExtra(OuterTwoStepPermissionActivity.GUIDE_TEXT_ROW_ONE, this.mContext.getString(R.string.huawei_permission_doze_step1_text));
//            intent.putExtra(OuterTwoStepPermissionActivity.GUIDE_TEXT_ROW_TWO, StringUtils.getFullStringWithAppName(R.string.huawei_permission_doze_step2_text));
//            intent.putExtra(OuterTwoStepPermissionActivity.GUIDE_TEXT_ROW_THREE, this.mContext.getString(R.string.huawei_permission_doze_step3_text));
//            intent.putExtra(OuterTwoStepPermissionActivity.GUIDE_IMG_ROW_ONE, WrapViewGenerator.getInstance().getViewByResId(R.drawable.huawei_permission_doze_step_1));
//            intent.putExtra(OuterTwoStepPermissionActivity.GUIDE_IMG_ROW_TWO, WrapViewGenerator.getInstance().getViewByResId(R.drawable.huawei_permission_doze_step_2));
//            intent.putExtra(OuterTwoStepPermissionActivity.GUIDE_IMG_ROW_THREE, WrapViewGenerator.getInstance().getViewByResId(R.drawable.huawei_permission_doze_step_3));
//            UiThreadExecutor.execute(new Runnable() {
//                public void run() {
//                    if (startIntentActivities) {
//                        HuaweiAL00PermissionStrategy.this.mContext.startActivity(intent);
//                    }
//                }
//            }, 100);
        } catch (Throwable e) {
        }
    }

    public ArrayList<String> getPermissionList() {
        ArrayList<String> arrayList = new ArrayList();
        for (Permission permission : ConfigHandler.getInstance().getPermissionList()) {
            switch (permission) {
                case TOAST:
                    arrayList.add(GuideConst.TOAST_PERMISSION);
                    break;
                case CALL_RINGTONE:
                case SHORTCUT:
                    break;
                case DIAL_NOTI:
//                    if(!PermissionListUtil.notificationListenerEnable())
                        arrayList.add(GuideConst.DIAL_NOTI_PERMISSION);
                    break;
                case AUTO_BOOT:
                    arrayList.add(GuideConst.AUTOBOOT_PERMISSION);
                    break;
                case BACKGROUND_PROTECT:
                    arrayList.add(GuideConst.BACKGROUND_PROTECT_PERMISSION);
                    break;
                case TRUST_APP:
                    arrayList.add(GuideConst.TRUST_APPLICATION_PERMISSION);
                    break;
                default:
                    break;
            }
        }
        return arrayList;
    }

    protected void actionDialNotiPermission() {
        super.actionDialNotiPermission();
        try {
            if (startIntentActivities(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"), GuideConst.DIAL_NOTI_PERMISSION, this.mAutoGuide)) {
//                Intent intent = new Intent(this.mContext, OuterPermissionActivity.class);
//                intent.putExtra(OuterPermissionActivity.VIEWSTUB_ID, R.layout.general_permission_guide_mask);
//                intent.putExtra(OuterPermissionActivity.GUIDEPIC_ID, WrapViewGenerator.getInstance().getViewByResId(R.drawable.permission_noti_vivo_4_0));
//                intent.putExtra(OuterPermissionActivity.GUIDE_HINTONE, StringUtils.getFullStringWithAppName(R.string.miui_permission_guide_template_one));
//                intent.putExtra(OuterPermissionActivity.GUIDE_HINTTWO, "");
//                this.mContext.startActivity(intent);
            }
        } catch (ActivityNotFoundException unused) {
        }
    }

    protected void actionCallRingtonePermission() {
        super.actionCallRingtonePermission();
    }

    protected void actionSystemDialingPermission() {
        super.actionSystemDialingPermission();
        IPermissionGuideStrategy.isDefaultPhoneApp();
    }
}
